package com.ln.第二遍1027.demo004;

import java.lang.reflect.Method;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/10/27 17:26
 */
public class Tset004 {
    public static void main(String[] args) throws Exception{
        Class<Pig> pigClass = Pig.class;
        Method ke = pigClass.getDeclaredMethod("ke");
        System.out.println("ke = " + ke);

        Method[] declaredMethods = pigClass.getDeclaredMethods();
        for (Method method :declaredMethods){
            System.out.println("method = " + method);
        }

        Method show = pigClass.getMethod("show");
        System.out.println("show = " + show);

        Method[] methods = pigClass.getMethods();
        for (Method method :methods){
            System.out.println("method = " + method);
        }
    }

}
class Cat{
    public void show(){
        System.out.println("猫的show方法");
    }
    private void hei(){
        System.out.println("猫的hei方法");
    }
}
class Pig extends Cat {
    public void ke(){
        System.out.println("猪的ke方法");
    }
    public void wu(String name,int age){
        System.out.println("猪的wu方法");
    }
}
